package com.caih.contacts.dao;
import com.caih.contacts.entity.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface DepartmentDao extends JpaRepository<Department,Integer>{
    @Query(value = "select d from Department d where  d.parent_id = ?1")
    public List<Department> queryByParentid(@Param("parent_id") Integer parent_id);

    @Modifying
    @Query(value = "delete from Department d where d.id = ?1")
    public void deleteById(Integer id);
}
